<?php
include("../qcubed.inc.php");

class SeasonListForm extends QForm {
    // Local instance of the Meta DataGrid to list Seasons
    protected $dtgSeasons;

    // Create QForm Event Handlers as Needed

//		protected function Form_Exit() {}
//		protected function Form_Load() {}
//		protected function Form_PreRender() {}
//		protected function Form_Validate() {}

    protected function Form_Run() {
        // Security check for ALLOW_REMOTE_ADMIN
        // To allow access REGARDLESS of ALLOW_REMOTE_ADMIN, simply remove the line below
        QApplication::CheckRemoteAdmin();
    }

    protected function Form_Create() {
        // Instantiate the Meta DataGrid
        $this->dtgSeasons = new SeasonDataGrid($this);

        // Style the DataGrid (if desired)
        $this->dtgSeasons->CssClass = 'datagrid';
        $this->dtgSeasons->AlternateRowStyle->CssClass = 'alternate';

        // Add Pagination (if desired)
        $this->dtgSeasons->Paginator = new QPaginator($this->dtgSeasons);
        $this->dtgSeasons->ItemsPerPage = 20;


        $this->dtgSeasons->AddRowAction(new QMouseOverEvent(), new QCssClassAction('selectedStyle'));
        $this->dtgSeasons->AddRowAction(new QMouseOutEvent(), new QCssClassAction());

        $this->dtgSeasons->RowActionParameterHtml = '<?= $_ITEM->Id ?>';
        $this->dtgSeasons->AddRowAction(new QClickEvent(), new QAjaxAction('dtgSeasonsRow_Click'));

        $this->dtgSeasons->MetaAddColumn('Name');
        $this->dtgSeasons->MetaAddColumn('DateFrom');
        $this->dtgSeasons->MetaAddColumn('DateTo');
        $this->dtgSeasons->MetaAddColumn('Active');
    }
    protected function dtgSeasonsRow_Click($strFormId, $strControlId, $strParameter) {
        $intId = intval($strParameter);
        $strEditPageUrl = __MASTERDATA__. '/season_edit.php/'. $intId;
        QApplication::Redirect($strEditPageUrl);
    }
}
SeasonListForm::Run('SeasonListForm','tpl/season_list.tpl.php');
?>
